package com.qf.commerce.controller;

import com.github.pagehelper.PageInfo;
import com.qf.commerce.common.vo.OrderListVo;
import com.qf.commerce.entity.Address;
import com.qf.commerce.entity.OrderList;
import com.qf.commerce.common.dto.OrderListDto;
import com.qf.commerce.resp.ResponseResult;
import com.qf.commerce.service.OrderListService;
import com.qf.commerce.vo.CommodityEvaluateVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 出品人:lsj
 * 1992915043@qq
 */
@RestController
@RequestMapping("/order")
public class OrderListController {

   @Autowired
   private OrderListService orderListService;

   @PostMapping("/status")
   public ResponseResult<OrderList> getOrderListByOrderStatus( Integer orderStatus) {
      try {
         return ResponseResult.success(orderListService.getOrderListByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * 询单页面
    * @param orderStatus
    * @return
    */
   @PostMapping("/Inquiry")
   public  ResponseResult<List<OrderList>> getInquiryByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getInquiryByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * 待付定金界面
    * @param orderStatus
    * @return
    */
   @PostMapping("/pending")
   public  ResponseResult<List<OrderList>> getDepositPendingByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getDepositPendingByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    *
    * 开启尾款支付
    * @param orderStatus
    * @return
    */
   @PostMapping("/payment")
   public  ResponseResult<List<OrderList>> getBalancePaymentByOrderStatusOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getBalancePaymentByOrderStatusOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    *
    * 待付尾款
    * @param orderStatus
    * @return
    */
   @PostMapping("/paid")
   public  ResponseResult<List<OrderList>> getBalancePaidByOrderStatusByOrderStatusOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getBalancePaidByOrderStatusByOrderStatusOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * 待收货
    * @param orderStatus
    * @return
    */
   @PostMapping("/await")
   public  ResponseResult<List<OrderList>> getAwaitReceiveGoodsByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getAwaitReceiveGoodsByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * getMultistageDeliveryByOrderStatus
    * 待付尾款-开启多阶段
    * @param orderStatus
    * @return
    */
   @PostMapping("/open")
   public  ResponseResult<List<OrderList>> getOpenMultiphaseByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getOpenMultiphaseByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * getRemainEevaluatedByOrderStatus
    * 待付尾款-多阶段发货
    * @param orderStatus
    * @return
    */
   @PostMapping("/delivery")
   public  ResponseResult<List<OrderList>> getMultistageDeliveryByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getMultistageDeliveryByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    *
    * 多阶段-待收货
    * @param orderStatus
    * @return
    */
   @PostMapping("/receive")
   public  ResponseResult<List<OrderList>> getAwaitReceiveGoodByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getAwaitReceiveGoodByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    *
    * 已完成订单
    * @param orderStatus
    * @return
    */
   @PostMapping("/complete")
   public  ResponseResult<List<OrderList>> getCompleteOrderByOrderStatusByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getCompleteOrderByOrderStatusByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    *
    * 待评价
    * @param orderStatus
    * @return
    */
   @PostMapping("/remain")
   public  ResponseResult<List<OrderList>> getRemainEevaluatedByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getRemainEevaluatedByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * 已取消订单
    * @param orderStatus
    * @return
    */
   @PostMapping("/cancelled")
   public  ResponseResult<List<OrderList>> getCancelledOrderByOrderStatus(Integer orderStatus){
      try {
         return  ResponseResult.success(orderListService.getCancelledOrderByOrderStatus(orderStatus));
      } catch (Exception e) {
         return ResponseResult.present();
      }
   }

   /**
    * 根据   订单号  支付方式  用户留言  商品名称  商品编码  买家名称 手机号进行模糊查询
    * @param orderListDto
    * @param page
    * @param size
    * @return
    */
   @GetMapping("/order/list")
   public  ResponseResult<PageInfo<OrderListVo>> getOrderPageByOrderList(@RequestBody OrderListDto orderListDto, @RequestParam(defaultValue = "1") Integer page,
                                                                         @RequestParam(defaultValue = "10") Integer size){
      try {
         return  ResponseResult.success(orderListService.getOrderPageByOrderList(orderListDto,page,size));
      } catch (Exception e) {
         return  ResponseResult.query();
      }

   }

   /**
    * getUpdateOrderList
    * 批量删除订单列表
    * @param orderId
    * @return
    */
   @PutMapping("/orderId")
   public  ResponseResult<Integer> deleteOrderList(@RequestBody List<Long> orderId){
      try {
         return ResponseResult.success(orderListService.deleteOrderList(orderId));
      } catch (Exception e) {
         return  ResponseResult.updateFailure();
      }
   }
   /**
    * 修改发货信息
    */
   @PutMapping("/address")
   public ResponseResult<Integer>  getUpdateOrderList(@RequestBody Address address){
      try {
         return  ResponseResult.success(orderListService.getUpdateOrderList(address));
      } catch (Exception e) {
         return  ResponseResult.updateFailure();
      }

   }


}
